using System;

namespace PentaBiz
{
    public abstract class Disposable : IDisposable
    {
        private bool _disposed;

        /// <summary>
        /// Called when [disposing].
        /// </summary>
        protected virtual void OnDisposing() { }

        /// <summary>
        /// Called when [finalizing].
        /// </summary>
        protected virtual void OnFinalizing() { }

        void Dispose(bool disposing)
        {
            if (_disposed)
                return;

            if (disposing)
                OnDisposing();
            else
                OnFinalizing();

            _disposed = true;
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        ~Disposable()
        {
            Dispose(false);
        }
    }
}